#!/usr/bin/env python
# -*- coding:utf-8 -*-
from django.shortcuts import render
from django.conf.urls import url
from stark.service.stark import StarkConfig, get_choice_text
from django import forms
from task import models


class ProjectModelForm(forms.ModelForm):
    class Meta:
        model = models.Project
        exclude = ['creator', ]
        widgets = {
            'content': forms.Textarea(attrs={'style': 'height:150px'}),
            'members': forms.CheckboxSelectMultiple(),
            'color': forms.RadioSelect(choices=models.Project.color_choices)
        }


class ProjectHandler(StarkConfig):
    model_form_class = ProjectModelForm

    def get_urls(self):
        urlpatterns = [
            url(r'^list/$', self.wrapper(self.changelist_view), name=self.get_list_url_name),
            url(r'^add/$', self.wrapper(self.add_view), name=self.get_add_url_name),
            # url(r'^(?P<pk>\d+)/change/', self.wrapper(self.change_view), name=self.get_change_url_name),
            # url(r'^(?P<pk>\d+)/del/', self.wrapper(self.delete_view), name=self.get_del_url_name),
        ]
        return urlpatterns

    def changelist_view(self, request):
        return render(request, 'task/project_list.html')
